package day2.homework;

import java.io.*;
import java.util.HashMap;
import java.util.Map;


// A~Z 65~90 a~z 97~122
public
class Demo5 {
    public static
    void main(String[] args) {
        try (FileReader fis=new FileReader("D:\\IO\\testIO.txt");
             FileWriter fos=new FileWriter("D:\\IO\\result.txt");)
        {
           Map<Character,Integer> ci=new HashMap<>();
           int len;
           while ((len=fis.read())!=-1){
            char c=(char) len;
            if(ci.containsKey(c)){
                ci.put(c,ci.get(c)+1);
            }else {
                ci.put(c,1);
            }
        }
           for (Character key:ci.keySet()){
               System.out.print(key+"("+ci.get(key)+"),");
               fos.write(key+"("+ci.get(key)+"),");
           }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
